package com.lanou.projecta_163news.fragment;

import android.net.Uri;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.MediaController;
import android.widget.VideoView;

import com.lanou.projecta_163news.R;
import com.lanou.projecta_163news.base.BaseFragment;
import com.lanou.projecta_163news.fragment.mainAdapter.ReadRecyclerAdapter;
import com.lanou.projecta_163news.fragment.mainAdapter.Video;
import com.lanou.projecta_163news.fragment.mainAdapter.VideoRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dllo on 16/3/9.
 */
public class VideoFragment extends BaseFragment {
    //    private VideoView videoView;
    private RecyclerView recyclerView;
    private VideoRecyclerAdapter videoRecyclerAdapter;
    private List<Video> videoData;

    @Override
    protected void initView() {
        recyclerView = bindView(R.id.video_recyclerview);


//        videoView = bindView(R.id.videoview);
    }

    @Override
    protected void initData() {
//        ininVideo();
        initRecycler();
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_video;
    }

    @Override
    protected ViewGroup getNull() {
        return null;
    }

//    private void ininVideo() {
//        videoView.setMediaController(new MediaController(getContext()));
//        Uri uri = Uri.parse("http://222.163.239.229/flv2.bn.netease.com/videolib3/1603/09/OoUpN9394/SD/OoUpN9394-mobile.mp4?wsiphost=local");
//        videoView.setVideoURI(uri);
//        videoView.requestFocus();
//
//    }

    private void initRecycler() {
        videoRecyclerAdapter = new VideoRecyclerAdapter();
        recyclerView.setAdapter(videoRecyclerAdapter);
        GridLayoutManager gm = new GridLayoutManager(getContext(),1);
        gm.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(gm);
        videoData = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            videoData.add(new Video("http://222.163.239.229/flv2.bn.netease.com/videolib3/1603/09/OoUpN9394/SD/OoUpN9394-mobile.mp4?wsiphost=local","hhh","jjjj"));
        }
        videoRecyclerAdapter.addvideoData(videoData);
    }
}
